<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <title>论坛</title>
    <head th:insert="~{import :: head}"></head>
</head>
<script type="application/javascript">
    window.onload = function () {
        let redirectUrl = sessionStorage.getItem("redirectUrl");
        let token = $.cookie('token');
        if (redirectUrl != null && redirectUrl !== "" && token != null && token !== "") {
            window.location.replace(redirectUrl);
            window.sessionStorage.removeItem("redirectUrl");
        }
    }
</script>
<body>
<div class="index-body">
    <div class="fixed-top" th:insert="~{navigation :: nav}"></div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-9 col-md-12 col-sm-12" th:if="${keyword == null && tag==null}">
                <ul class="list-group list-group-horizontal ">
                    <a th:href="@{/(tab='latest')}"
                       th:classappend="${activeTab == 'latest'} ? 'active' : ''"
                       class="list-group-item list-group-item-action">
                        <h2 class="text-center">最新</h2>
                    </a>
                    <a th:href="@{/(tab='popular')}"
                       th:classappend="${activeTab == 'popular'} ? 'active' : ''"
                       class="list-group-item list-group-item-action">
                        <h2 class="text-center">总热度</h2>
                    </a>
                    <a th:href="@{/(tab='weekly')}"
                       th:classappend="${activeTab == 'weekly'} ? 'active' : ''"
                       class="list-group-item list-group-item-action">
                        <h2 class="text-center">本周热门</h2>
                    </a>
                    <a th:href="@{/(tab='monthly')}"
                       th:classappend="${activeTab == 'monthly'} ? 'active' : ''"
                       class="list-group-item list-group-item-action">
                        <h2 class="text-center">本月热门</h2>
                    </a>
                    <a th:href="@{/(tab='oldest')}"
                       th:classappend="${activeTab == 'oldest'} ? 'active' : ''"
                       class="list-group-item list-group-item-action">
                        <h2 class="text-center">从旧到新</h2>
                    </a>
                </ul>

                <hr>
                <div class="media" th:each="post : ${paginationDTO.data}">
                    <div class="media-left">
                        <a th:href="${'user/'+post.user.id}">
                            <img th:src="${post.user.avatarUrl}" class="media-object picture-margin img-thumbnail" alt="...">
                        </a>
                    </div>
                    <div class="media-body ">
                        <h4 class=" mt-0">
                            <a class="href" th:href="@{'/post/'+${post.id}}" th:text="${post.title}"></a>
                        </h4>
                        <span th:if="${post.plainText!=null}" th:text="${#strings.abbreviate(post.plainText, 140)}"></span>
                        <br>
                        <span class="text-desc col-lg-12 col-md-12 col-sm-12"><span th:text="${post.commentCount}"></span> 回复
                            <span th:text="${post.viewCount}"></span> 浏览 <span th:text="${#dates.format(post.gmtCreate,'yy.MM.dd')}"></span>
                            <span class="float-right">最后修改 <span th:text="${#dates.format(post.gmtModified,'yy.MM.dd')}"></span></span>
                        </span>
                    </div>
                </div>
                <div th:unless="${not #lists.isEmpty(paginationDTO.getData)}">
                    <div class="alert alert-danger alert-dismissible fade show" role="alert">错误</div>
                </div>
                <nav aria-label="Page navigation example">
                    <ul class="pagination">
                        <li th:if="${paginationDTO.showFirstPage}" class="page-item">
                            <a class="page-link" aria-label="Previous"
                               th:href="@{/(page=1, tab=${activeTab != null ? activeTab : 'latest'})}">
                                <span aria-hidden="true">首页</span>
                            </a>
                        </li>
                        <li th:if="${paginationDTO.showPrevious}" class="page-item">
                            <a class="page-link" aria-label="Previous"
                               th:href="@{/(page=${paginationDTO.page -1}, tab=${activeTab != null ? activeTab : 'latest'})}">
                                <span aria-hidden="true">&lt;</span>
                            </a>
                        </li>
                        <li th:each="page: ${paginationDTO.pages}"
                            th:class="${paginationDTO.page == page}?'page-item active':'page-item'">
                            <a class="page-link"
                               th:href="@{/(page=${page}, tab=${activeTab != null ? activeTab : 'latest'})}"
                               th:text="${page}"></a>
                        </li>
                        <li th:if="${paginationDTO.showNext}" class="page-item">
                            <a class="page-link" aria-label="Next"
                               th:href="@{/(page=${paginationDTO.page +1}, tab=${activeTab != null ? activeTab : 'latest'})}">
                                <span aria-hidden="true">&gt;</span>
                            </a>
                        </li>
                        <li th:if="${paginationDTO.showEndPage}" class="page-item">
                            <a class="page-link" aria-label="Next"
                               th:href="@{/(page=${paginationDTO.totalPage}, tab=${activeTab != null ? activeTab : 'latest'})}">
                                <span aria-hidden="true">尾页</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="col-lg-9 col-md-12 col-sm-12" th:if="${keyword != null}">
                <h2>
                    <svg class="bi bi-search" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                        <path fill-rule="evenodd" d="M10.442 10.442a1 1 0 0 1 1.415 0l3.85 3.85a1 1 0 0 1-1.414 1.415l-3.85-3.85a1 1 0 0 1 0-1.415z"/>
                        <path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM13 6.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0z"/>
                    </svg>
                    搜索结果: "<span th:text="${keyword}"></span>"
                </h2>
                <hr>
                <div class="media" th:each="post : ${paginationDTO.data}">
                    <div class="media-left">
                        <a th:href="${'user/'+post.user.id}">
                            <img th:src="${post.user.avatarUrl}" class="media-object picture-margin img-thumbnail" alt="...">
                        </a>
                    </div>
                    <div class="media-body ">
                        <h4 class=" mt-0">
                            <a class="href" th:href="@{'/post/'+${post.id}}" th:text="${post.title}"></a>
                        </h4>
                        <span th:if="${post.plainText!=null}" th:text="${#strings.abbreviate(post.plainText, 140)}"></span>
                        <br>
                        <span class="text-desc col-lg-12 col-md-12 col-sm-12"><span th:text="${post.commentCount}"></span> 回复
                            <span th:text="${post.viewCount}"></span> 浏览 <span th:text="${#dates.format(post.gmtCreate,'yy.MM.dd')}"></span>
                            <span class="float-right">最后修改 <span th:text="${#dates.format(post.gmtModified,'yy.MM.dd')}"></span></span>
                        </span>
                    </div>
                </div>
                <div th:unless="${not #lists.isEmpty(paginationDTO.getData)}">
                    <div class="alert alert-danger alert-dismissible fade show" role="alert">错误</div>
                </div>
                <ul class="pagination">
                    <li th:if="${paginationDTO.showFirstPage}" class="page-item">
                        <a class="page-link" aria-label="Previous"
                           th:href="@{'/search?keyword=' + ${keyword} + '&page=1'}">
                            <span aria-hidden="true">首页</span>
                        </a>
                    </li>
                    <li th:if="${paginationDTO.showPrevious}" class="page-item">
                        <a class="page-link" aria-label="Previous"
                           th:href="@{'/search?keyword=' + ${keyword} + '&page=' + ${paginationDTO.page -1}}">
                            <span aria-hidden="true">&lt;</span>
                        </a>
                    </li>

                    <li th:each="page: ${paginationDTO.pages}"
                        th:class="${paginationDTO.page == page}?'page-item active':'page-item'">
                        <a class="page-link"
                           th:href="@{'/search?keyword=' + ${keyword} + '&page=' + ${page}}"
                           th:text="${page}"></a>
                    </li>

                    <li th:if="${paginationDTO.showNext}" class="page-item">
                        <a class="page-link" aria-label="Next"
                           th:href="@{'/search?keyword=' + ${keyword} + '&page=' + ${paginationDTO.page +1} }">
                            <span aria-hidden="true">&gt;</span>
                        </a>
                    </li>
                    <li th:if="${paginationDTO.showEndPage}" class="page-item">
                        <a class="page-link" aria-label="Next"
                           th:href="@{'/search?keyword=' + ${keyword} + '&page=' + ${paginationDTO.totalPage}}">
                            <span aria-hidden="true">尾页</span>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="col-lg-9 col-md-12 col-sm-12" th:if="${tag != null}">
                <h2>
                    <svg class="bi bi-search" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                        <path fill-rule="evenodd" d="M10.442 10.442a1 1 0 0 1 1.415 0l3.85 3.85a1 1 0 0 1-1.414 1.415l-3.85-3.85a1 1 0 0 1 0-1.415z"/>
                        <path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM13 6.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0z"/>
                    </svg>
                    Tag: "<span th:text="${tag}"></span>"
                </h2>
                <hr>
                <div class="media" th:each="post : ${paginationDTO.data}">
                    <div class="media-left">
                        <a th:href="${'user/'+post.user.id}">
                            <img th:src="${post.user.avatarUrl}" class="media-object picture-margin img-thumbnail" alt="...">
                        </a>
                    </div>
                    <div class="media-body ">
                        <h4 class=" mt-0">
                            <a class="href" th:href="@{'/post/'+${post.id}}" th:text="${post.title}"></a>
                        </h4>
                        <span th:if="${post.plainText!=null}" th:text="${#strings.abbreviate(post.plainText, 140)}"></span>
                        <br>
                        <span class="text-desc col-lg-12 col-md-12 col-sm-12"><span th:text="${post.commentCount}"></span> 回复
                            <span th:text="${post.viewCount}"></span> 浏览 <span th:text="${#dates.format(post.gmtCreate,'yy.MM.dd')}"></span>
                            <span class="float-right">最后修改 <span th:text="${#dates.format(post.gmtModified,'yy.MM.dd')}"></span></span>
                        </span>
                    </div>
                </div>
                <div th:unless="${not #lists.isEmpty(paginationDTO.getData)}">
                    <div class="alert alert-danger alert-dismissible fade show" role="alert">错误</div>
                </div>
                <ul class="pagination">
                    <li th:if="${paginationDTO.showFirstPage}" class="page-item">
                        <a class="page-link" aria-label="Previous"
                           th:href="@{'/search-tag/' +${tag}+'?page=1'}">
                            <span aria-hidden="true">首页</span>
                        </a>
                    </li>
                    <li th:if="${paginationDTO.showPrevious}" class="page-item">
                        <a class="page-link" aria-label="Previous"
                           th:href="@{'/search-tag/' + ${tag} + '?page=' + ${paginationDTO.page -1}}">
                            <span aria-hidden="true">&lt;</span>
                        </a>
                    </li>

                    <li th:each="page: ${paginationDTO.pages}"
                        th:class="${paginationDTO.page == page}?'page-item active':'page-item'">
                        <a class="page-link"
                           th:href="@{'/search-tag/' + ${tag} + '?page=' + ${page}}"
                           th:text="${page}"></a>
                    </li>

                    <li th:if="${paginationDTO.showNext}" class="page-item">
                        <a class="page-link" aria-label="Next"
                           th:href="@{'/search-tag/' + ${tag} + '?page=' + ${paginationDTO.page +1} }">
                            <span aria-hidden="true">&gt;</span>
                        </a>
                    </li>
                    <li th:if="${paginationDTO.showEndPage}" class="page-item">
                        <a class="page-link" aria-label="Next"
                           th:href="@{'/search-tag/' + ${tag} + '?page=' + ${paginationDTO.totalPage}}">
                            <span aria-hidden="true">尾页</span>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="col-lg-3 col-md-12 col-sm-12" >
                <div th:if="${keyword == null && tag == null}">
                    <h3>热门话题</h3>
                    <div class="hot-tags">
                        <a th:each="hotTag : ${hotTags}"
                           th:href="@{/search-tag/{tag}(tag=${hotTag})}"
                           class="badge badge-pill badge-info tag">
                            <svg class="bi bi-tag" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                <path fill-rule="evenodd" d="M.5 2A1.5 1.5 0 0 1 2 .5h4.586a1.5 1.5 0 0 1 1.06.44l7 7a1.5 1.5 0 0 1 0 2.12l-4.585 4.586a1.5 1.5 0 0 1-2.122 0l-7-7A1.5 1.5 0 0 1 .5 6.586V2zM2 1.5a.5.5 0 0 0-.5.5v4.586a.5.5 0 0 0 .146.353l7 7a.5.5 0 0 0 .708 0l4.585-4.585a.5.5 0 0 0 0-.708l-7-7a.5.5 0 0 0-.353-.146H2z"/>
                                <path fill-rule="evenodd" d="M2.5 4.5a2 2 0 1 1 4 0 2 2 0 0 1-4 0zm2-1a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
                            </svg>
                            <text th:text="${hotTag}"></text>
                        </a>
                    </div>
                    <hr>
                </div>
                <h4>广告</h4>
                <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                        <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                        <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                        <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
                    </ol>
                    <div class="carousel-inner">
                        <div class="carousel-item active">
                            <a href="https://ngabbs.com/read.php?tid=41989465" target="_blank">
                                <img src="/images/nga.jpg" class="d-block w-100" alt="...">
                            </a>
                        </div>
                        <div class="carousel-item">
                            <a href="https://ngabbs.com/read.php?tid=41989465" target="_blank">
                                <img src="/images/nga.jpg" class="d-block w-100" alt="...">
                            </a>
                        </div>
                        <div class="carousel-item">
                            <a href="https://ngabbs.com/read.php?tid=41989465" target="_blank">
                                <img src="/images/nga.jpg" class="d-block w-100" alt="...">
                            </a>
                        </div>
                    </div>
                    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="sr-only">Next</span>
                    </a>
                </div>
            </div>
        </div>
    </div>


</div>
</body>
</html>